/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-23
 * Time: 18:02
 */

import java.util.Scanner;

public class test2{
    public static int myAtoi(String s) {
        int slen=s.length();
        char[] chars=s.substring(5,slen-1).toCharArray();
        boolean flag1=true;
        boolean flag2=true;
        boolean flag3=true;
        String res="";
        for (char c : chars)
        {
            if(flag1)
            {
                if(c==' '||c=='0')
                    continue;
                if((c=='+'||c=='-')&&flag2)
                {
                    flag2=false;
                    System.out.println(flag2);
                    if(c=='-')
                        res+=c;
                }
                else if(c<'0'||c>'9')
                {
                    res="0";
                    break;
                }
                else
                {
                    res+=c;
                    flag3=false;
                }
                flag1=false;
                continue;
            }
            if(flag3)
            {
                if (c=='0')
                    continue;
                else if(c<'0'||c>'9')
                {
                    res+='0';
                    break;
                }
                flag3=false;
            }
            if(c>='0'&&c<='9')
                res+=c;
            else
                break;


        }
        return Integer.parseInt(res);
    }

    public static void main(String[] args) {
        myAtoi("     0-1");
    }
}

